<template>
  <div id="MyintegralDetail" class="lot_det">
    <div class="title">
      <i></i>
      <span>任务基本信息</span>
    </div>
    <div class="detail clearfix">
      <ul>
        <li v-for="(val,key,index) in item" :key="val+index+'y'" v-show="index<4">
          <span>{{key}}</span>
          <label :title="val">
            <i>{{val}}</i>
          </label>
        </li>
      </ul>
      <ul>
        <li v-for="(val,key,index) in item" :key="val+index+'x'" v-show="index>3">
          <span>{{key}}</span>
          <label>
            <em v-if="val=='不予结算'">
              {{val}}
              <div class="tips" :title="reason">{{reason}}</div>
            </em>
            <i v-else>{{val}}</i>
          </label>
        </li>
      </ul>
    </div>
    <div v-if="bad!=null" class="title">
      <i></i>
      <span>坏数据占比</span>
    </div>
    <div v-if="bad!=null" class="detail clearfix">
      <ul>
        <li>
          <span>坏数据条数</span>
          <label>
            <i>{{bad.badCount}}</i>
          </label>
        </li>
      </ul>
      <ul>
        <li>
          <span>坏数据占比</span>
          <label>
            <i>{{bad.badCountRatio}}</i>
          </label>
        </li>
      </ul>
    </div>
    <div class="title">
      <i></i>
      <span>文件列表</span>
      <div class="sea-lt">
        <input type name placeholder="请输入文件名称" v-model="postData.fileName" />
        <a class="ser-btn" v-on:click="search">查询</a>
      </div>
    </div>
    <div class="noneresult" v-if="contentNull">暂无数据</div>
    <div class="table con-list" v-else>
      <table width="100%">
        <thead>
          <tr>
            <td>文件名称</td>
            <td>正确率</td>
            <td>操作</td>
          </tr>
        </thead>
        <tbody>
          <tr v-for="ob in list" :key="ob.name">
            <td>{{ob.name}}</td>
            <td>{{ob.accuracyRate | toPercentage}}</td>
            <td>
              <a class="rem-btn" v-on:click="seeresult(ob)">查看结果</a>
            </td>
          </tr>
        </tbody>
      </table>
    </div>
    <!-- <div class="pagesize" id="pagesize" v-if="!contentNull"></div> -->
    <el-pagination v-show="list && list.length > 0"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :page-sizes="[1, 2, 3]"
      :page-size.sync="pagination.pageSize"
      :current-page.sync="pagination.currPage"
      layout="sizes, prev, pager, next"
      :total.sync="pagination.total">
    </el-pagination>
  </div>
</template>
<script>
export default {
  name:"MyintegralDetail",
  data(){
    return{
      item:null,
      taskId:'',
      markTaskId:'',
      cycle:'',
      integralId:'',
      bad:null,
      reason:null,
      list: null,
      pageSize: 10,
      contentNull: false,
      postData: {
          fileName: ''
      },
    pagination: { // 分页配置
        currPage: 1,
        pageSize: 10,
        total: 0,
        handleSizeChange: this.handleSizeChange,
        handleCurrentChange: this.handleCurrentChange
    }, 
    }
  },
  created(){
    this.taskId = this.Utils.getQueryStringArgs().taskId;
    this.markTaskId = this.Utils.getQueryStringArgs().markTaskId;
    this.cycle = this.Utils.getQueryStringArgs().cycle;
    this.integralId = this.Utils.getQueryStringArgs().id;
  },
  mounted: function() {
      let self = this;
      self.ass_api.integralDetail({
        selectType: 'my_integral',
        markTaskId: this.markTaskId,
        cycle: this.cycle,
        integralId: this.integralId
      }).then(data => {
        if(!data) return;
        self.item = data.result;
        if(("badCount" in data.extend)){
            self.bad = data.extend;
        }
        if(("reason" in data.extend)){
            self.reason = data.extend.reason;
        }
        self.search();
      })
  },
  methods: {
        handleSizeChange(val){
            console.log(`${val}页面展示多少条`)
            this.search()
        },
        handleCurrentChange(val){
            console.log(`${val}当前多少页`)
            this.search()
        },

      search() {
            let self = this;
            self.postData['taskId'] = self.taskId;
            self.postData['markTaskId'] = self.markTaskId;
            self.postData.currPage = self.pagination.currPage;
            self.postData.pageSize = self.pagination.pageSize;
            // 分页请求 
            self.ass_api.integralFileList(self.postData).then(data => {
                    if(!data) return;
                    if (data.list == undefined || data.list == null || data.list == "") {
                        self.list = null;
                        self.contentNull = true;
                    } else {
                        self.list = data.list;
                        self.contentNull = false;
                    }
                    self.pagination.pageSize = data.pageSize == 0 ? 10 : data.pageSize;
                    self.pagination.total = data.count;
            })
      },
      seeresult: function(flag) { //查看结果
          var url = "/assets/home/result-page/?markTaskId=" + this.markTaskId + '&taskId=' + this.taskId + '&fileid=' + flag.fileId;
          window.open(url, 'markresult-myintegral');
      },
  },
  filters:{
    toPercentage:function(value) {
        var f = parseFloat(value);
        if (isNaN(f)) {
            return "--";
        }
        var rate = (parseInt(Number(value) * 10000) / 100).toFixed(2);
        return rate + "%";
    }
  }
}
</script>
<style lang="less" scoped>
    .MyintegralDetail{
        width: 100%; 
        background: rgb(255, 255, 255); 
        height: 100%; 
        padding: 20px;
        margin: 0px; 
        border: 0px; 
        text-align: left;
    }
    .lot_det{
        padding: 20px 20px 45px 20px;
        background: #fff;
        // width: 1000px;
        // border-left: 20px solid #f2f3f4;
        // margin-left: 200px;
        min-height: 800px;
        .title{
            line-height: 16px;
            font-weight: bold;
            font-size: 16px;
            padding-bottom: 20px;
            border-bottom: 1px solid #ececec;
            position: relative;
            margin-bottom: 20px;
        }
        .title i{
            height: 14px;
            width: 4px;
            background: #14cb6b;
            margin-right: 5px;
            display: inline-block;
        }
        .sea-lt{
            position: absolute;
            right: 0;
            top: -10px;
            box-sizing: content-box;
        }
        .sea-lt span{
            float: left;
            margin-right: 10px;
            line-height: 31px;
        }
        .sea-lt input{
            height: 34px;
            line-height: 34px;
            border-radius: 2px;
            border: 1px solid #e0e0e0;
            padding-left: 10px;
            width: 280px;
            float: left;
            margin-right: 10px;
        }
        .sea-lt a{
            background: #fcad1d;
            color: #fff;
            border-radius: 2px;
            width: 74px;
            text-align: center;
            display: inline-block;
            float: right;
            height: 34px;
            line-height: 34px;
            font-size: 14px;
            float: left;
        }
        .sea-lt a:hover{
            background: #e07900;
        }
        .progressList tr td{border:1px solid #ececec;}
    }
.detail{
    border:1px solid #ececec;
    margin-bottom: 50px;
    ul{
        float: left;
        width: 50%;
    }
    ul li{
        height: 40px;
        line-height: 40px;
    }
    ul li:not(:last-child){
        border-bottom: 1px dashed #ececec;
    }
    ul li span{
        width: 40%;
        float: left;
        background: #fafafa;
        display: inline-block;
        text-align: center;
        height: 39px;
        line-height: 37px;
        border-right: 1px solid #ececec;
        color: #969696;
    }
    ul li label{
        display: inline-block;
        padding-left: 30px;
        width: 58%;
    }
    ul li label i{
        width: 100%;
        display: inline-block;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    ul li:last-child span{
        height: 40px;
        line-height: 40px;
    }
    ul:not(:first-child) span{
        border-left: 1px solid #ececec;
    }
    ul li label i{font-style: normal;}
    ul li label em{position: relative; font-style: normal;}
    ul li label em:after {
        content: "?";
        position: absolute;
        right: -30px;
        top: 3px;
        width: 16px;
        height: 16px;
        display: block;
        text-align: center;
        line-height: 16px;
        background: #dfdfdf;
        color: #fff;
        -webkit-border-radius: 8px;
        -moz-border-radius: 8px;
        -ms-border-radius: 8px;
        -o-border-radius: 8px;
        border-radius: 8px;
        font-size: 12px;
    }
    ul li label:hover em:after {
        background: #fcad1d;
    }
    ul li label em .tips{
        width: 188px;
        display: none;
        border: 1px solid #f6d4b9;
        background: #fff4ec;
        color: #fbae22;
        position: absolute;
        left: 65px;
        top: 34px;
        word-break: break-all;
        line-height: 1.5;
        padding: 4px 15px;
        -webkit-border-radius: 2px;
        -moz-border-radius: 2px;
        -ms-border-radius: 2px;
        -o-border-radius: 2px;
        border-radius: 2px;
        z-index: 99;
        font-size: 14px;
        -webkit-box-shadow: 0px 0px 10px rgba(252,173,29,0.4);
        -moz-box-shadow: 0px 0px 10px rgba(252,173,29,0.4);
        -ms-box-shadow: 0px 0px 10px rgba(252,173,29,0.4);
        -o-box-shadow: 0px 0px 10px rgba(252,173,29,0.4);
        box-shadow: 0px 0px 10px rgba(252,173,29,0.4);
    }
    ul li label em .tips:before{content:"";position:absolute;left:4px;top:-14px;border-width:7px;border-style:dashed dashed solid dashed; border-color:transparent transparent #f6d4b9 transparent;font-size:0; line-height:0;}
    ul li label em .tips:after{content:"";position:absolute;left:4px;top:-13px;border-width:7px;border-style:dashed dashed solid dashed; border-color:transparent transparent #fff4ec transparent;font-size:0; line-height:0;}
    ul li label em:hover .tips{ display:block;}
}

.con-list{
    margin-bottom: 35px;
    border: 1px solid #eeeeee;
    table thead{
        height: 45px;
        line-height: 45px;
        border-bottom: 1px solid #eeeeee;
        background: #fafafa;
        color: #969696;
    }
    table tbody{
        height: 45px;
        line-height: 45px;
        background: #fff;
    }
    table tr:nth-child(even){
        border-top: 1px dashed #eeeeee;
    }
    table tr:not(:last-child) {
        border-bottom: 1px dashed #ececec;
    }
    table tr td:not(:first-child) {
        max-width: 150px;
    }
    table  tr td{
        text-align: center;
        font-size: 14px;
        height: 45px;
        word-break: break-word;
        padding: 0 5px;
        line-height: initial;
    }
    table tr td:not(:first-child) div {
        white-space: nowrap;
        margin-right: 0;
        overflow: hidden;
        padding: 0;
        text-overflow: ellipsis;
    }
    td{
        height: 45px;
        line-height: 45px;
        text-align: center;
    }
    tr td{ border:0; padding: 0;}
    table tr td .rem-btn {
        color: rgb(51, 204, 0);
        cursor: pointer;
    }
}


</style>    